package org.example.core.utils;

/**
 * @author 小杰_cc
 * @version 1.0
 */

import com.github.pagehelper.PageInfo;
import lombok.Getter;

import java.io.Serializable;
import java.util.List;

/**
 * 分页工具类
 */
@Getter
public class PageUtils implements Serializable {

    private static final long serialVersionUID = 1L;

    // 总记录数
    private int total;

    // 每页记录数
    private int pageSize;

    // 总页数
    private int pages;

    // 当前页数
    private int page;

    // 列表数据
    private List<?> list;

    /**
     * 分页
     */
    public PageUtils(PageInfo<?> pageInfo) {
        this.list = pageInfo.getList();
        this.total = (int)pageInfo.getTotal();
        this.pageSize = pageInfo.getSize();
        this.page = pageInfo.getPageNum();
        this.pages = pageInfo.getPages();
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public void setPages(int pages) {
        this.pages = pages;
    }

    public void setPage(int pageNum) {
        this.page = pageNum;
    }

    public void setList(List<?> list) {
        this.list = list;
    }

}
